Ext.define('js.title.top', {
    extend: 'Ext.panel.Panel',
    layout: 'card',
    region:'north',//指定显示区域
    height:50,
    border:false,
    id:'cardprotop',
    initComponent: function () {
        let alarmCountRate = Ext.create('Ext.Component',
            {
                html:
                '<nav class="navbar navbar-expand-sm navbar-dark" style="height:80px;">' +
                '  <!-- Brand/logo -->' +
                '<div style="width:60%">' +
                '<p class="title_style" style="float: left;margin-top: -40px;margin-left:10px;">宜阳县住建工程管理系统</p>' +
                '</div>' +
                '<div style="width:15%;font-size: 16px;margin-top: 50px;display:inline-block;">' +
                '<span id="clockTxt"style="position: absolute;top:20px;font-size:16px;"></span>' +
                '</div>' +
                '<div  style="width:11%">' +
                '<a  href="#"  style="text-decoration:none" onclick="modifiPwd()"><img src="../img/admin.png" class="img-circle" alt="logo" style="width:16px;height:20px; margin-top:-26px"/> ' +
                '<span class="name_style" style="font-size:16px;">'+ Ext.userData.userName+'</span></a>' +
                '</div>' +
                '<div style="width:10%;margin-top: -22px;">' +
                '<ul class="navbar-nav">' +
                '<li class="nav-item">' +
                ' <a class="nav-link" href="#" onclick="backMyPage();" style="cursor:pointer;font-size:24px;color:#ffffff; "><img src="../img/home.png" style="width:21px; height:18px;"/></a>' +
                '</li>' +
                '<li class="nav-item">' +
                '  <a class="nav-link" onclick="vim()" href="#" style="cursor:pointer;font-size:24px; margin-left:80px;margin-right:20px;color:#ffffff"><img src="../img/close.png" style="width:18px; height:18px;"/></a>' +
                '</li>' +
                ' </ul>' +
                '</div>' +
                '</nav>'
            });
        this.items = [alarmCountRate];
        this.on('afterrender', this.clockFn);
        this.callParent(arguments);
    },
    clockFn: function () {
        var newDate = '';
        getLangDate();
        function dateFilter(date){ //值小于10时，在前面补0
            if(date < 10){
                return "0"+date;
            }
            return date;
        }
        function getLangDate(){

            var dateObj = new Date(); //表示当前系统时间的Date对象
            var year = dateObj.getFullYear(); //当前系统时间的完整年份值
            var month = dateObj.getMonth()+1; //当前系统时间的月份值
            var date = dateObj.getDate(); //当前系统时间的月份中的日
            var day = dateObj.getDay(); //当前系统时间中的星期值
            var weeks = ["周日","周一","周二","周三","周四","周五","周六"];
            var week = weeks[day]; //根据星期值，从数组中获取对应的星期字符串
            var hour = dateObj.getHours(); //当前系统时间的小时值
            var minute = dateObj.getMinutes(); //当前系统时间的分钟值
            var second = dateObj.getSeconds(); //当前系统时间的秒钟值
            var timeValue = "" +((hour >= 12) ? (hour >= 18) ? "晚上" : "下午" : "上午" ); //当前时间属于上午、晚上还是下午
            newDate = dateFilter(year)+"-"+dateFilter(month)+"-"+dateFilter(date)+"             "+dateFilter(week);
            if(Ext.get('clockTxt') !== null)
                Ext.get('clockTxt').setHtml(newDate);
            setTimeout(getLangDate,1000);
        }
    }
});